//首页js暴露接口
Array.prototype.in_array = function(e)
	{
	for(i=0;i<this.length;i++)
	{
	if(this[i] == e)
	return true;
	}
	return false;
}
expelocal.indexFun = function(){
	return {
		init:function(){
			var _this = this;
			_this.bannerFun();
			_this.searchFun();
		},
		bannerFun:function(){
			var $banContent = $('.banner'),
				$picContent = $('.banner-list'),
				$btnContnt = $('.slide-btn'),
				$liLen = $picContent.find('li').length,
				$prveBtn = $banContent.find('.prve'),
				$nextBtn = $banContent.find('.next'),
				iNum = 0,
				timer = null;
			//图片和按钮切换函数
			function picSlideFun(index){
				$picContent.find('li').stop(true,true).fadeOut().eq(index).stop(true,true).fadeIn();
				$btnContnt.find('a').removeClass('cur').eq(index).addClass('cur');
			};
			//点击下一张按钮
			$nextBtn.on('click',function(){
				nextFun()
			});
			//点击上一张按钮
			$prveBtn.on('click',function(){
				iNum > 0?iNum--:iNum=$liLen-1;
				picSlideFun(iNum);
			});
			//小圆点点击切换
			$btnContnt.on('click','a',function(){
				var _index = $(this).index();
				iNum = _index;
				picSlideFun(iNum);
			});
			function nextFun(){
				iNum < $liLen-1?iNum++:iNum=0;
				picSlideFun(iNum);
			};
			// 定时器开启
			timer = setInterval(nextFun,5000);
			$banContent.on('mouseenter',function(){
				clearInterval(timer);
				$('.jiantou').show();
			});
			$banContent.on('mouseleave',function(){
				timer = setInterval(nextFun,5000);
				$('.jiantou').hide();
			});
		},
		//搜索框输入
		searchFun:function(){
			var htmlTip = '<div id="autoTip"></div>';
			$('.search-bar').append($(htmlTip));
			$('#search').on('keyup',function(){
				var $this = $(this),
					$text = $this.val();
				if($text){
					$.ajax({
			            type: 'GET',
			            url:comHost + '/home/search',
			            data:{keyword:$text},
			            dataType: "jsonp",
			            jsonp: 'jsonpCallback',
			            success: function(data){
				            var _html = '';
				            console.log(data);
			            	if(data.length > 0){
			            		for(var i =0; i<data.length;i++){
			            			console.log(!!data[i].producttype);
			            			if(data[i].producttype){
			            				_html += '<span data-url='+comHost+ '/' + data[i].producttype +'Themes-'+ data[i].location +'-Default-1.html>'+data[i].name+'</span>';
			            			}else{
			            				_html += '<span data-url='+comHost+'/ALLThemes-'+ data[i].location +'-Default-1.html>'+data[i].name+'</span>';
			            			}
			            		}
			            	}else{
		            			_html += '';
			            		_html += '<span data-url='+comHost+'/AllThemes-Default-1.html?keyword='+ $text +'>'+ $text +'</span>';
			            		
			            	}
				            $('#autoTip').html($(_html));
			            }
			        })
		        }
			});
			$('.search-bar').on('click', 'span', function (event) {
			    window.location.href = $(this).attr('data-url');
			    event.stopPropagation();
			});
			$('.searchBtn').on('click', function (event) {
				var $this = $('#search').val();
				window.location.href = comHost + '/AllThemes-Default-1.html?keyword=' + $this;
				event.stopPropagation();
			});
			$(document).on('click', function () {
			    $('#autoTip').html('');
			});
			$(document).keyup(function (e) {
			    var curKey = e.which;
			    if (curKey == 13) {
			        $('.searchBtn').trigger('click');
			    };
			});
		}
	}
};
//产品列表页js暴露接口
expelocal.productListFun = function(){
	return {
		init:function(){
			var _this = this;
			_this.prodetHoverFun();
			_this.addLoveFun();
			_this.moreBtn();
		},
	    //点击更多
		moreBtn: function () {
		    $('.cote-con').on('click', '.more-btn', function () {
		        var $this = $(this);
		        if ($this.hasClass('showMore')) {
		            $this.removeClass('showMore');
		            $this.siblings('.items').css('height', '24px');
		            $this.html('展开∨');
		        } else {
		            $this.addClass('showMore');
		            $this.siblings('.items').css('height', 'auto');
		            $this.html('收起∧');
		        }

		    });
		},
	    //产品图片鼠标移过效果
		prodetHoverFun: function () {
		    $('.product-lists').on('mouseenter', '.product', function () {
		        var $this = $(this);
		        $this.find('.infos').show();
		    });
		    $('.product-lists').on('mouseleave', '.product', function () {
		        var $this = $(this);
		        $this.find('.infos').hide();
		    });
		},
		//加入心愿单
		addLoveFun:function(){
			$('.product-lists').on('click','.product .Love',function(){
			    var $this = $(this).parents('li'),
                    $that = $(this),
					$pId = $this.attr('data-id'),
					$pCode = $this.attr('data-code');
			    if ($that.hasClass('cur')) {
			        
			        $.ajax({
			            type: 'GET',
			            url: comHost + '/Member/CancelFavorite',
			            data: { pid: $pId },
			            dataType: "jsonp",
			            jsonp: 'jsonpCallback',
			            success: function (data) {
			                var nData = data;
			                if (nData.code == 200) {
			                    $that.removeClass('cur');
			                } else {
			                    if (nData.result == 'ikutoken') {
			                        layer.open({
			                            title: false,
			                            type: 0,
			                            content: '请先登录！'
			                        });
			                    } else {
			                        layer.open({
			                            title: false,
			                            type: 0,
			                            content: nData.msg
			                        });
			                    }
			                }
			            }
			        });
			    } else {
			        $.ajax({
			            type: 'GET',
			            url: comHost + '/Member/AddFavorite',
			            data: { pid: $pId, pcode: $pCode },
			            dataType: "jsonp",
			            jsonp: 'jsonpCallback',
			            success: function (data) {
			                console.log(data);
			                var nData = data;
			                if (nData.code == 200) {
			                    $that.addClass('cur');
			                } else {
			                    $that.removeClass('cur');
			                    if (nData.result == 'ikutoken') {
			                        layer.open({
			                            title: false,
			                            type: 0,
			                            content: '请先登录！'
			                        });
			                    } else {
			                        layer.open({
			                            title: false,
			                            type: 0,
			                            content: nData.msg
			                        });
			                    }
			                }
			            }
			        });
			    }
			});
		}
	}
};
//产品列详情页js暴露接口
expelocal.productDetailFun = function(){
	return {
		init:function(){
			var _this = this;
			_this.bannerFun();
			_this.floatLayerFun();
			_this.reserveFun();
			_this.buyNowFun();
			// _this.mapFun();
			_this.detailAddloveFun();
			_this.shareFun();
		},
		shareFun:function(){
			$('#cloneFloatLayer').find('.share-btn').hover(function(){
				$(this).find('.s-a').show();
			},function(){
				$(this).find('.s-a').hide();
			})
		},
	    //收藏功能
		detailAddloveFun: function () {
		    $('.title-con').on('click', '.sc-btn i', function () {
		        var $this = $(this);
		        $pId = $this.attr('data-id'),
                $pCode = $this.attr('data-code');
		        if ($this.hasClass('cur')) {
		            $.ajax({
		                type: 'GET',
		                url: comHost + '/Member/CancelFavorite',
		                data: { pid: $pId },
		                dataType: "jsonp",
		                jsonp: 'jsonpCallback',
		                success: function (data) {
		                    var nData = data;
		                    if (nData.code == 200) {
		                        $this.removeClass('cur');
		                        $('#cloneFloatLayer').find('.sc-btn').removeClass('cur');
		                    } else {
		                        if (nData.result == 'ikutoken') {
		                            layer.open({
		                                title: false,
		                                type: 0,
		                                content: '请先登录！'
		                            });
		                        } else {
		                            layer.open({
		                                title: false,
		                                type: 0,
		                                content: nData.msg
		                            });
		                        }
		                    }
		                }
		            });
		        } else {
		        	$.ajax({
		                type: 'GET',
		                url: comHost + '/Member/AddFavorite',
		                data: { pid: $pId, pcode: $pCode },
		                dataType: "jsonp",
		                jsonp: 'jsonpCallback',
		                success: function (data) {
		                    console.log(data);
		                    var nData = data;
		                    if (nData.code == 200) {
		                        $this.addClass('cur');
		                        $('#cloneFloatLayer').find('.sc-btn').addClass('cur');
		                    } else {
		                        if (nData.result == 'ikutoken') {
		                            layer.open({
		                                title: false,
		                                type: 0,
		                                content: '请先登录！'
		                            });
		                        } else {
		                            layer.open({
		                                title: false,
		                                type: 0,
		                                content: nData.msg
		                            });
		                        }
		                    }
		                }
		            });
		        }
		    });
			
			$('#cloneFloatLayer').on('click','.sc-btn',function(){
				$('.title-con').find('.sc-btn i').trigger('click');
			});
		},
		// 图片切换
		bannerFun:function(){
			var $banCon = $('.pic-slide-con'),
				$picCon = $banCon.find('.pic-items'),
				$btnCon = $banCon.find('.slide-btn'),
				$leftBtn = $banCon.find('.left-btn'),
				$rightBtn = $banCon.find('.right-btn'),
				$len = $picCon.find('li').length,
				iNow = 0,
				timer = null;
			function autoSlide(index){
				$picCon.find('li').hide().eq(index).show();
				$btnCon.find('a').removeClass('cur').eq(index).addClass('cur');
			};
			$btnCon.on('click','a',function(){
				var _index = $(this).index();
				iNow = _index;
				autoSlide(iNow);
			});
			function nextFun(){
				iNow++;
				if(iNow > $picCon.find('li').length-1){
					iNow = 0;
				}
				autoSlide(iNow);
			};
			$leftBtn.on('click',function(){
				if(iNow > 0){
					iNow --;
				}else{
					iNow = $len-1;
				};
				autoSlide(iNow);
			});
			$rightBtn.on('click',function(){
				if(iNow < $len-1){
					iNow ++;
				}else{
					iNow = 0;
				};
				autoSlide(iNow);
			});
			// 定时器开启
			timer = setInterval(nextFun,5000);
			$banCon.on('mouseenter',function(){
				clearInterval(timer);
			});
			$banCon.on('mouseleave',function(){
				timer = setInterval(nextFun,5000);
			});
		},
		//浮层导航
		floatLayerFun:function(){
			var layerTop = $('.float-layer').offset().top,
				cloneLayer = $('.float-layer').clone();
			$(window).scroll(function(e){
				var scrTop = $(this).scrollTop();
				if(scrTop >= layerTop){
					$('#cloneFloatLayer').prepend(cloneLayer).show();
					$('.main-right').addClass('fixed');
				}else{
					$('.main-right').removeClass('fixed');
					$('#cloneFloatLayer').hide();
				}
			});
			$('#cloneFloatLayer,.float-layer').on('click','li',function(){
				var $this = $(this),
					_index = $this.index(),
					$modulTop = $('.model-section').eq(_index).offset().top;
					$('html,body').animate({scrollTop:$modulTop-80},500);

				$('#cloneFloatLayer').find('li').eq(_index).addClass('cur').siblings('li').removeClass('cur');
				$('.float-layer').find('li').eq(_index).addClass('cur').siblings('li').removeClass('cur');
			});
		},
		//请求日历数据
		getData:function(year,month,pid,callback){
			$.ajax({
	            type: 'GET',
	            url:comHost + '/play/AvailableInfo',
	            data:{
	            	pid:pid,
	            	year:year,
	            	month:month
	        	},
	            dataType: "jsonp",
	            jsonp: 'jsonpCallback',
	            success: function(data){
	            	callback(data);
	            }
	        })
		},
		//立即预定
		reserveFun:function(){
			var _this = this;
			//点击贪层
			$('.yuding-con').on('click','.yb-btn',function(){
				layer.open({
				  type: 1,
				  title: false,
				  scrollbar: false,
				  area: '880px',
				  skin: 'layui-layer-nobg',
				  shadeClose: true,
				  content: $('#paymentDiv')
				});
			});
			$('#ljydBtn').on('click',function(){
				$('.yuding-con').find('.yb-btn').trigger('click');
			});
	        var date = new Date(); //当前Date资讯
	        var sfullYear = date.getFullYear(); //获取年份
		    var sMonth = date.getMonth(); //获取月份，返回值是0(一月)到11(十二月)之间的一个整数。

			//判断是否为闰年
	        function is_leap(year) {
	            //闰年的条件是符合下面二者之一：
	            //(1)年份能被4整除，但不能被100整除；
	            //(2)年份能被400整除。
	            if((year%4==0 && year%100!=0)||(year%400==0)){
	                return 1;
	            }
	            return 0;
	        };
	        var pid = $('#pid').val();
	        changeDataFun(sfullYear,sMonth,pid);

	        //上一个月
	        $('#myDateTime').on('click','.month-lft',function(){
	        	var aYear = $('#myDateTime').find('.year-month').attr('data-year'),
	        		aMonth = $('#myDateTime').find('.year-month').attr('data-month')-2;
	        	if(aMonth>=sMonth){
	        		changeDataFun(aYear,aMonth,pid);
	        	}else{
	        		return false;
	        	}
	        });
	        //下一个月
	        $('#myDateTime').on('click','.month-rgt',function(){
	        	var aYear = $('#myDateTime').find('.year-month').attr('data-year'),
	        		aMonth = $('#myDateTime').find('.year-month').attr('data-month');
	        	changeDataFun(aYear,aMonth,pid);

	        });
	        function changeDataFun(sfullYear,sMonth,pid){
	        	var fullYear = sfullYear; //获取年份
		        var aMonth = sMonth; //获取月份，返回值是0(一月)到11(十二月)之间的一个整数。
		        var month = parseInt(aMonth)+1;
		        var sMonth = month <10?'0' + month : month;
		        var date_of_month = date.getDate(); //获取日期，返回值是1~31之间的一个整数
		        var first_date = new Date(fullYear, aMonth, 1); //获取当前月第一天Date资讯
		        //返回date对象星期中的一天，此值为0(周日)-6(周六)之间的一个整数
		        var week = first_date.getDay(); //获取当前月第一天是星期几
		        var days_of_month = new Array(31, 28+is_leap(fullYear), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //各月份的总天数
		        var rows = Math.ceil((days_of_month[aMonth] + week) / 7); //表格所需要行数

		        _this.getData(fullYear,month,pid,function(res){
					var newData = res,
						nDateList = newData.datelist,
						nPsList = newData.pslist,
						nOptionList = newData.optionlist,
						nPriceList = newData.pricelist,
						nSkuList = newData.skulist;
					var dateHtml = '';
					console.log(res);
					$('#fjfw-content').hide();
					$('#fjfwList').html('');

			        dateHtml += '<div class="year-month" data-year="'+ fullYear +'" data-month="'+ month +'"><span class="month-lft"><b></b></span><span class="month-fc"></span>'+ fullYear +'年'+ month +'月 <span class="month-rgt"><b></b></span></div>';
			        dateHtml+='<table id="table" width="708px;" cellpadding="5" cellspacing="1">';
			        dateHtml+="<tr>";
			        dateHtml+="<td align='center'>日</td>";
			        dateHtml+="<td align='center'>一</td>";
			        dateHtml+="<td align='center'>二</td>";
			        dateHtml+="<td align='center'>三</td>";
			        dateHtml+="<td align='center'>四</td>";
			        dateHtml+="<td align='center'>五</td>";
			        dateHtml+="<td align='center'>六</td>";
			        dateHtml+="</tr>";
			        //打印表格第一行（有星期标志）
			        var dataListArr = [];
	                for(var i = 0; i<nDateList.length;i++){
	                	var strDate = nDateList[i]['date'];
	                	dataListArr.push(nDateList[i]['date'].split(' ')[0].split('-')[2]);
	                };
			        for (i = 0; i < rows; i++) { //表格的行
			            dateHtml += "<tr>";
			            for (k = 0; k < 7; k++) { //表格每行的单元格
			                idx = i * 7 + k; //单元格自然序列号
			                date_str = idx - week + 1; //计算日期
			                //过滤无效日期（小于等于零的、大于月总天数的）
			                (date_str <= 0 || date_str > days_of_month[aMonth]) ? date_str = "&nbsp;" : date_str = idx - week + 1; 	
			                var sdateStr = date_str <10?'0' + date_str : date_str;
			                //打印日期：今天底色为红
			                if(dataListArr.in_array(date_str)){
			                	dateHtml += "<td align='center' class='usable' data-day='" + sMonth + "-"+ sdateStr + "'>" + date_str + "</td>";
			                }else{
			                	dateHtml += "<td align='center' class='nousable'>" + date_str + "</td>";
			                }
			            }
			            dateHtml += "</tr>"; //表格的行结束
			        }
			        dateHtml += "</table>"; //表格结束
			        $('#myDateTime').html(dateHtml);

			        //sku添加
			        var skuHtml = '';
			        for(var i = 0; i<nSkuList.length;i++){
			        	skuHtml += '<span id="'+nSkuList[i].id+'" data-sku="'+ nSkuList[i].name +'" data-max="'+ nSkuList[i].maxbook +'" data-index="'+ i +'">'+ nSkuList[i].name +'</span>';
			        };
			        $('#skuList').html(skuHtml);
			        //人数选择
			        var fieldHtml = '';
			        for(var i = 0; i< nPsList.length;i++){
			        	if(nPsList[i].type == "PERSON"){
			        		fieldHtml += '<div class="field-select cf" s_psid="'+nPsList[i].s_psid+'" minprice="" data-num="0" data-max="10" data-min="0">';
		                	fieldHtml += '<div class="field-type" travellertype="1" person="'+ nPsList[i].crowd_type +'">';
		                	fieldHtml += nPsList[i].name_cn +'<span class="field-range">('+ nPsList[i].desc +')</span></div>';
		                	fieldHtml += '<div class="num-counter">';
		                	fieldHtml += '<span class="reduce">-</span>';
		                	fieldHtml += '<input class="nums" value="0">';
		                	fieldHtml += '<span class="add">+</span></div>';
		                	fieldHtml += '<div class="field-price"><em style="display: none;"> ¥ <span class="price"></span></em></div>';
		                	fieldHtml += '</div>';
			        	}else{
			        		fieldHtml += '<div class="field-select cf"  s_psid="'+nPsList[i].s_psid+'" minprice="" data-num="0" data-max="10" data-min="0">';
		                	fieldHtml += '<div class="field-type" travellertype="1">';
		                	fieldHtml += '<span class="field-range">'+ nPsList[i].name_cn +'</span></div>';
		                	fieldHtml += '<div class="num-counter">';
		                	fieldHtml += '<span class="reduce">-</span>';
		                	fieldHtml += '<input class="nums" value="0">';
		                	fieldHtml += '<span class="add">+</span></div>';
		                	fieldHtml += '<div class="field-price"><em style="display: none;"> ¥ <span class="price"></span></em></div>';
		                	fieldHtml += '</div>';
			        	}
			        };
			        $('#field-text').html(fieldHtml);
			        //减少
			        $('#field-text').find('.reduce').off('click').on('click', function () {
			        	var $this = $(this),
			        		$val = $this.siblings('.nums').val(),
			        		minNum = $this.parents('.field-select').attr('data-min') || 0,
			        		maxNum = $this.parents('.field-select').attr('data-max') || 100,
			        		price = $this.parents('.field-select').find('[data-price]').attr('data-price');
			        	if($val > minNum && $val >1){
			        		$val--;
			        		$this.parents('.field-select').find('[data-price]').text($val*price);
			        	}else{
			        		$val = 0;
			        		$this.parents('.field-select').find('[data-price]').text(price);
			        	};
			        	
			        	$this.parents('.field-select').attr('minprice',price).attr('data-num',$val);
			        	$this.siblings('.nums').val($val);
			        	//总价格计
			        	_this.allPrice();
			        });
			        //增加
			        $('#field-text').find('.add').off('click').on('click', function () {
			        	var $this = $(this),
			        		$val = parseInt($this.siblings('.nums').val()),
			        		maxNum = $this.parents('.field-select').attr('data-max') || 100,
			        		minNum = $this.parents('.field-select').attr('data-min') || 0,
			        		price = $this.parents('.field-select').find('[data-price]').attr('data-price');
			        	if($('#myDateTime').find('.selected').length>0 || $('#skuList').find('.cur').length > 0){
			        		if($val < minNum && $val >= 0){
			        			$val = minNum;
			        		}else if($val >= minNum && $val< maxNum){
			        			$val++;
			        		}else{
				        		$val=maxNum;
				        	};	
				        	
				        	$this.parents('.field-select').find('[data-price]').text($val*price);
				        	$this.parents('.field-select').attr('minprice',price).attr('data-num',$val);
				        	$this.siblings('.nums').val($val);
				        	//总价格计
				        	_this.allPrice();
			        	}
			        });
			        $('#fjtc-text').off('click','.reduce').on('click','.reduce',function(){
			        	var $this = $(this),
			        		$val = parseInt($this.siblings('.nums').val()),
			        		maxNum = $this.parents('.field-select').attr('data-max') || 100,
			        		minNum = $this.parents('.field-select').attr('data-min') || 0;
			        	if($val > minNum && $val >1){
			        		$val--;
			        	}else{
			        		$val = 0;
			        	};
			        	$this.siblings('.nums').val($val);
			        	$this.parents('.field-select').attr('data-num',$val);
			        });

			        $('#fjtc-text').off('click','.add').on('click','.add',function(){
			        	var $this = $(this),
			        		$val = parseInt($this.siblings('.nums').val()),
			        		maxNum = $this.parents('.field-select').attr('data-max') || 100,
			        		minNum = $this.parents('.field-select').attr('data-min') || 0;
			        	if($val < minNum){
			        			$val=minNum;
			        		}else{
			        			if($val< maxNum){
					        		$val++;
					        	}else{
					        		$val=maxNum;
					        	};	
			        		}
			        	$this.siblings('.nums').val($val);
			        	$this.parents('.field-select').attr('data-num',$val);
			        });
			        // 点击日期
			        $('#myDateTime').off('click','.usable').on('click','.usable',function(){
			        	var $this = $(this),
			        		bCurDay = $this.attr('data-day').split('-'),
			        		cCurDay = bCurDay[1],
			        		aCurDay = bCurDay[0]+'-'+cCurDay,
			        		skuIdArr = [],
			        		$curDay =fullYear +'-'+ aCurDay;;
			        	

	        			$('#field-text').find('.field-select em').hide();
		        		$('#field-text').find('.field-select .price').text('');
		        		$('#field-text').find('.field-select .nums').val(0);
		        		$('#field-text').find('.field-select .price').attr('data-price','');
		        		$('#field-tc').html('');
			        	if($this.hasClass('selected')){
			        		$this.removeClass('selected');
			        		$('#field-date').html('* 请选择');

			        		//如果没有选择日期取消价格显示
			        		var $field = $('#field-text').find('.field-select');
	        				for(var j = 0;j<$field.length;j++){
	        					$field.eq(j).find('.field-price em').hide();
        						$field.eq(j).attr('minprice','');
        						$field.eq(j).find('.price').attr('data-cj','')
        						$field.eq(j).find('.price').text('');
	        				};
	        				$('#skuList').find('span').removeClass('disableSku');
			        	}else{
			        		$('.usable').removeClass('selected');
			        		$this.addClass('selected');
			        		// console.log($('#paymentDiv').find('.tcxz-items').html());

				        	for(var i = 0;i<nPriceList.length;i++){
				        		if(nPriceList[i].saledate.indexOf(aCurDay) != -1){
				        			skuIdArr.push(nPriceList[i].skuid);
				        			$('#field-date').html($curDay);
				        		}
				        	};
					        for(var i = 0 ;i<skuIdArr.length;i++){
					        	$('#'+skuIdArr[i]).removeClass('disableSku');
					        };

			        		//显示价格
			        		if($('#paymentDiv').find('.tcxz-items .cur').length > 0){
			        			var curTcArr = $('#skuList').find('span.cur'),
			        				skuId = curTcArr.attr('id');
			        				$('#field-tc').html(curTcArr.html());
			        			// console.log(skuId);
				        		for(var i = 0;i<nPriceList.length; i++){
				        			if($curDay == nPriceList[i].saledate.split(' ')[0] && skuId == nPriceList[i].skuid){
				        				var $field = $('#field-text').find('.field-select');
				        				for(var j = 0;j<$field.length;j++){
				        					if($field.eq(j).attr('s_psid').toUpperCase() == nPriceList[i].spid.toUpperCase()){
				        						// console.log(nPriceList[i].retailprice,nPriceList[i].saleprice);
				        						$field.eq(j).find('.field-price em').show();
				        						$field.eq(j).attr('minprice',nPriceList[i].saleprice);
				        						$field.eq(j).find('.price').attr('data-cj',nPriceList[i].retailprice-nPriceList[i].saleprice)
				        						$field.eq(j).attr('data-max',nPriceList[i].max_num);
				        						$field.eq(j).attr('data-min',nPriceList[i].min_num);
				        						$field.eq(j).find('.price').text(nPriceList[i].saleprice).attr('data-price',nPriceList[i].saleprice);
				        					};
				        				}
				        			}
				        		};
				        		_this.allPrice();
			        		}

		       				var skuSpan = $('#skuList').find('span');
		       				skuSpan.addClass('disableSku');
					       	for(var i = 0 ;i < nDateList.length;i++){
					       		if($curDay == nDateList[i].date.split(' ')[0]){
					       			for(var k = 0;k<nDateList[i].skulist.length;k++){
					       				$('#'+nDateList[i].skulist[k].skuid).removeClass('disableSku');
					       			}
					       			return;
					       		}
					       	}
				        };
			        });

					//套餐点击
					$('#skuList').off('click','span:not(.disableSku)').on('click','span:not(.disableSku)',function(){
						var $this = $(this),
							skuId = $this.attr('id'),
							_index =$this.attr('data-index'), 
							$fjfwHtml = '',
							$curDay = $('#myDateTime').find('.selected').attr('data-day'),
							$curYear = $('#myDateTime').find('.year-month').attr('data-year');
						$this.siblings('span').removeClass('cur');
						$('#field-text').find('.field-select .nums').val(0);
						$('#field-text').find('.field-select em').hide();
		        		$('#field-text').find('.field-select .price').text('');
		        		$('#field-text').find('.field-select .price').attr('data-price','');
						$('#fjtc-text').html('');
						if($this.hasClass('cur')){
							$this.removeClass('cur');
			        		$('#field-tc').html('');
			        		$('#skuMaxVal').val(0);
			        		//如果没有选择套餐取消价格显示
			        		var $field = $('#field-text').find('.field-select');
	        				for(var j = 0;j<$field.length;j++){
	        					$field.eq(j).find('.field-price em').hide();
        						$field.eq(j).attr('minprice','');
        						$field.eq(j).find('.price').attr('data-cj','')
        						$field.eq(j).find('.price').text('');
	        				};
	        				$('#fjfw-content').hide();
				        	$('#field-fw').parent('p').hide();
			        	}else{
			        		$this.addClass('cur');
			        		$('#field-tc').html($this.attr('data-sku'));
			        		$('#skuMaxVal').val($this.attr('data-max'));
			        		//显示价格
				        	if($curDay){
				        		$('#field-date').html($curYear+'-'+$curDay);
				        		$curDay =fullYear +'-'+ $curDay;
				        		for(var i = 0;i<nPriceList.length; i++){
				        			if($curDay == nPriceList[i].saledate.split(' ')[0] && skuId == nPriceList[i].skuid){
				        				var $field = $('#field-text').find('.field-select');
				        				for(var j = 0;j<$field.length;j++){
				        					if($field.eq(j).attr('s_psid').toUpperCase() == nPriceList[i].spid.toUpperCase()){
				        						$field.eq(j).find('.field-price em').show();
				        						$field.eq(j).attr('minprice',nPriceList[i].saleprice);
				        						$field.eq(j).attr('data-max',nPriceList[i].max_num);
				        						$field.eq(j).attr('data-min',nPriceList[i].min_num);
				        						$field.eq(j).find('.price').text(nPriceList[i].saleprice).attr('data-price',nPriceList[i].saleprice);
				        					}
				        				}
				        				
				        			}
				        		}

				        		var skuOption = nSkuList[_index].optionlist;
					        	if(skuOption.length > 0){
				        			for(var i = 0 ;i<skuOption.length;i++){
						        		if(skuOption[i].skuid == skuId){
						        			var group = skuOption[i].group?skuOption[i].group:'';
						        			$('#fjfw-content').show();
						        			if(group){
						        				$fjfwHtml += '<span data-id="'+skuOption[i].option_code+'" data-cj="0" data-max="'+skuOption[i].max+'" data-min="'+skuOption[i].min+'" data-group="'+group+'" data-price="'+skuOption[i].price+'"  data-sku="'+skuOption[i].option_name+'" class="group">'+skuOption[i].option_name+'</span>';	
						        			}else{
						        				$fjfwHtml += '<span data-id="'+skuOption[i].option_code+'" data-cj="0" data-max="'+skuOption[i].max+'" data-min="'+skuOption[i].min+'" data-group="'+group+'" data-price="'+skuOption[i].price+'"  data-sku="'+skuOption[i].option_name+'">'+skuOption[i].option_name+'</span>';
						        			}
						        			
						        		}else{
						        			$('#fjfw-content').hide();
						        		};
						        	};
						        	$('#fjfwList').show();
						        	$('#fjfwList').html($fjfwHtml);
					        	}else{
					        		$('#fjfw-content').hide();
					        		$('#field-fw').parent('p').hide();
					        	};
					        	//总价格计
					        	_this.allPrice();
				        	}else{
				        		$('#field-date').html('* 请选择');
				        		layer.open({
									title: false,
									type: 0,
									content:"请选择日期！"
								});
				        	}

			        	};
					});

			        //附加服务
		        	var $fjfwCont = $('#fjfw-content');
			        $fjfwCont.off('click','span').on('click','span',function(){
			        	var $this = $(this),
			        		$isGroup = $this.attr('data-group');

		        		var fieldHtmls = '',
							fjfwHtml='';
			        	if($isGroup){
			        		if($this.hasClass('cur')){
								$this.removeClass('cur');
								fieldHtml = '';
				        	}else{
			        			$('#fjfw-content').find('.group').removeClass('cur');
				        		$this.addClass('cur');
				        	};
			        	}else{
			        		if($this.hasClass('cur')){
								$this.removeClass('cur');
				        	}else{
				        		$this.addClass('cur');
				        	};
			        	};
			        	for(var i = 0 ;i < $fjfwCont.find('.cur').length;i++){
			        		fieldHtmls += '<div class="field-select cf" id="'+ $fjfwCont.find('.cur').eq(i).attr("data-id") +'" data-max="'+ $fjfwCont.find('.cur').eq(i).attr("data-max") +'" data-min="'+ $fjfwCont.find('.cur').eq(i).attr("data-min") +'" minprice="'+ $fjfwCont.find('.cur').eq(i).attr("data-price") +'" data-num="">';
		                	fieldHtmls += '<div class="field-type" travellertype="1">';
		                	fieldHtmls += '<span class="field-range">'+ $fjfwCont.find('.cur').eq(i).attr("data-sku") +'</span></div>';
		                	fieldHtmls += '<div class="num-counter">';
		                	fieldHtmls += '<span class="reduce">-</span>';
		                	fieldHtmls += '<input class="nums" value="0">';
		                	fieldHtmls += '<span class="add">+</span></div>';
		                	fieldHtmls += '<div class="field-price"><em> ¥ <span class="price"  data-cj="'+ $fjfwCont.find('.cur').eq(i).attr("data-cj") +'" data-price="'+ $fjfwCont.find('.cur').eq(i).attr("data-price") +'">'+ $fjfwCont.find('.cur').eq(i).attr("data-price") +'</span></em></div>';
		                	fieldHtmls += '</div>';

		                	fjfwHtml +=$fjfwCont.find('.cur').eq(i).attr("data-sku")+' ';
	                	};

			        	if($fjfwCont.find('.cur').length > 0){
			        		$('#field-fw').parent('p').show();
			        		$('#field-fw').html(fjfwHtml)
			        	}else{
							$('#field-fw').parent('p').hide();
							$('#field-fw').html('')
			        	}
			        	$('#fjtc-text').html(fieldHtmls);
						_this.allPrice();
			        })
				});
	        }
			
		},
		//总价格计算
		allPrice:function(){
			var fieldText = $('.field-select'),
				priceArr = [],
				cjPriceArr = [];
			for(var i =0; i<fieldText.length;i++){
				if(fieldText.eq(i).attr('minprice')){
					priceArr.push(fieldText.eq(i).find('.nums').val()*fieldText.eq(i).find('.price').attr("data-price"));
					cjPriceArr.push(fieldText.eq(i).find('.nums').val()*fieldText.eq(i).find('.price').attr("data-cj"));
				}
			}
			var allPrice = eval(priceArr.join('+')) || 0,
				cjPrice = eval(cjPriceArr.join('+')) || 0;
			$('#totalMoney').find('b').html("¥"+allPrice.toFixed());
			$('#totalMoney').attr('data-price',allPrice.toFixed())
			$('#savingMoney').find('span').html("¥"+cjPrice.toFixed());
		},
		// 立即预订提交信息
		buyNowFun: function () {

		    $('#buyNow').on('click', function () {
		        var specsArr = [],
					tcArr = [];
		        for (var i = 0; i < $('#field-text .field-select').length; i++) {
		            var $field = $('#field-text .field-select').eq(i);
		            if ($field.attr('data-num') > 0) {
		                specsArr.push($field.attr("s_psid") + '$' + $field.attr('minprice') + '$' + $field.attr('data-num'));
		            }
		        };
		        var skuMaxVal = $('#skuMaxVal').val();
		        if(skuMaxVal != 0 || skuMaxVal != "0"){
		        	var txNum = 0;
		        	$('#field-text').find('.field-select').each(function(){
		        		txNum += parseInt($(this).find('.nums').val());
		        	});

		        	if(txNum > skuMaxVal){
			        	layer.open({
			                title: false,
			                type: 0,
			                content: "该套餐可预定的最大套餐为"+skuMaxVal
			            });
			            return false;
		        	}
		        };
		        $('#fmSpecs').val(specsArr.join(';'));
		        if ($('#myDateTime').find('.selected').length > 0) {
		            $('#fmStartdate').val($('#field-date').text());
		        } else {
		            layer.open({
		                title: false,
		                type: 0,
		                content: "请选择日期！"
		            });
		            return false;
		        };
		        $('#fmTotal').val($('#totalMoney').attr('data-price'));
		        if ($('#skuList').find('.cur').length > 0) {
		            $('#fmSkuid').val($('#skuList').find('.cur').attr('id'));
		        } else {
		            layer.open({
		                title: false,
		                type: 0,
		                content: "请选择套餐！"
		            });
		            return false;
		        };
		        if ($('#fjfw-content').find('.cur').length > 0) {
		            for (var i = 0; i < $('#fjfw-content').find('.cur').length; i++) {
		            	var $field = $('#fjtc-text .field-select').eq(i);
		                tcArr.push($('#fjfw-content').find('.cur').eq(i).attr('data-id') + '$' + $field.attr('minprice') + '$' + $field.attr('data-num'));
		            }
		            $('#fmOptions').val(tcArr.join(';'));
		        } else {
		            $('#fmOptions').val('');
		        };
		        if ($('#totalMoney').attr('data-price') > 0) {
		            var dataJson = {
		                pid: $("#pid").val(),
		                specs: $("#fmSpecs").val(),
		                startdate: $("#fmStartdate").val(),
		                enddate: $("#fmEnddate").val(),
		                total: $("#fmTotal").val(),
		                skuid: $("#fmSkuid").val(),
		                options: $("#fmOptions").val()
		            };
		            console.log(dataJson);
		            if (Cookies.get('ikutoken')) {
		                $.ajax({
		                    type: 'GET',
		                    url: comHost + '/play/CheckPrice',
		                    data: dataJson,
		                    dataType: "jsonp",
		                    beforeSend: function () {
		                        $('.loding').show();
		                    },
		                    jsonp: 'jsonpCallback',
		                    success: function (data) {
		                        var nData = data;
		                        if (nData.result == "true") {
		                            $('.loding').hide();
		                            window.location.href = comHost + "/play/orderconfirm.html?" + $(".fm").serialize();
		                        } else {
		                            $('.loding').hide();
		                            if (data.code == "400") {

		                                layer.open({
		                                    title: false,
		                                    type: 0,
		                                    content: nData.msg,
		                                    end: function () {
		                                        location.reload();
		                                    }
		                                });
		                                
		                            } else if (data.code == "404") {

		                                layer.open({
		                                    title: false,
		                                    type: 0,
		                                    content: nData.msg,
		                                    end: function () {
		                                        location = "../home/index";
		                                    }
		                                });

		                            } else {
		                                layer.open({
		                                    title: false,
		                                    type: 0,
		                                    content: nData.msg
		                                });
		                            }
		                        }
		                    }
		                });
		            } else {
		                layer.open({
		                    title: false,
		                    type: 0,
		                    content: '请先登录！'
		                });
		            }
		        }
		    });
		},

		//标注地图
		mapFun:function(){
			var $lat =  $('#lat').val(),
				$lon =  $('#lon').val();
			

				var geocoder = new google.maps.Geocoder();
		        var map, marker;
		        function initialize() {
		            var longitude = $lon;
		            var latitude = $lat;
		            var latLng = new google.maps.LatLng(latitude, longitude);
		            map = new google.maps.Map(document.getElementById('map_canvas'), {
		                zoom: 16,
		                center: latLng,
		                mapTypeId: google.maps.MapTypeId.ROADMAP
		            });
		            marker = new google.maps.Marker({
		                position: latLng,
		                title: 'Point A',
		                icon:"../img/pointer.png",
		                map: map,
		                draggable: false
		            });
		        }
		        // 加载载应用程序。
		        google.maps.event.addDomListener(window, 'load', initialize);
		}
	}
};
expelocal.orderConfirm = function(){
	return {
		init:function(){
			var _this = this;
			_this.incAjaxFun();
			_this.submitFun();
		},
		incAjaxFun:function(){
			var _this = this;
			var dataJson = {
				pid:$("#pid").val(),
				specs:$("#specs").val(),
				startdate:$("#startdate").val(),
				enddate:$("#enddate").val(),
				total:$("#total").val(),
				skuid:$("#skuid").val(),
				options:$("#options").val()
			};
			//$.ajax({
	        //    type: 'GET',
	        //    url:comHost + '/play/GetBookLimit',
	        //    data:{skuid:dataJson.skuid},
	        //    dataType: "jsonp",
	        //    jsonp: 'jsonpCallback',
	        //    success: function(data){
	        //    	// console.log(data);
	        //    	_this.addParsenFun(data);
	        //    }
	        //});
			 //$.ajax({
	         //    type: 'GET',
	         //    url:comHost + '/play/CheckPrice',
	         //    data:dataJson,
	         //    dataType: "jsonp",
	         //    jsonp: 'jsonpCallback',
	         //    success: function(data){
	         //    	var nData = data;
	         //    	if(nData.result == true){
	         //    		layer.open({
			 //				title: false,
			 //				type: 0,
			 //				content:nData.msg
			 //			});
	         //    	}else{
	             	    $.ajax({
	             	        type: 'GET',
	             	        url: comHost + '/play/GetBookLimit',
	             	        data: { skuid: dataJson.skuid },
	             	        dataType: "jsonp",
	             	        jsonp: 'jsonpCallback',
	             	        success: function (data) {
	             	            // console.log(data);
	             	            _this.addParsenFun(data);
	             	        }
	             	    });
	         //    	}
	         //    }
	         //});

		},
		addParsenFun:function(data){
			var nData = data,
				allHtml = "",
				nDataTravel = nData.booklimit_travellers[0],
				speccountArr = $('#speccount').val().split(';');

			var _ahtml = '<li class="chageLi"><span>联系电话：</span><input type="text" class="t-srk" data-name="phone" value=""/></li>';

			$('#lkxxContent').on('click','.setLx',function(){
				$('#lkxxContent').find('.setLx').removeClass('set');
				$(this).addClass('set');
				$('#lkxxContent').find('.chageLi').remove();
				$(this).parents('.lkxx-modle').find('.com-items').append(_ahtml);
				$('.idLeader').val(0);
				$(this).parents('.lkxx-modle').find('.idLeader').val(1);
			});
		},
		//下一步
		submitFun:function(){
			var dataObj = {};

			$('input[name="needinvoice"]').on('click', function () {
			    var $this = $(this),
					_index = $this.parent('label').index();
			    switch (_index) {
			        case 1:
			            $this.parents('.com-items').find('li:gt(0)').show();
			            break;
			        case 2:
			            $this.parents('.com-items').find('li:gt(0)').hide();
			            break;
			    }
			});
			$('input[data-name="need_birthday"],input[data-name="identity_start_date"],input[data-name="identity_expire_date"]').keydown(function(event) {
				return false;
			});

			$('input[name="jsxx"]').on('click',function(){
				var $this = $(this),
					_index = $this.parents('li').index();
				if(_index == 0){
					$('input[data-name="pickupplace_i"]').attr("disabled","disabled");
					$('.data-select').removeAttr("disabled");
				}else{
					$('.data-select').attr("disabled","disabled");
					$('input[data-name="pickupplace_i"]').removeAttr("disabled");
				}
				
			});

			$('#submitBtn,.p-btn').on('click',function(){
				var firstnameArr = [];
				$('input[data-name="firstname"]').each(function(i){
					firstnameArr.push({'firstnameVla':$(this).val(),'languageVal':$(this).attr('language')});
				})
				for(var i =0; i<firstnameArr.length;i++){
					if(firstnameArr[i]['firstnameVla'] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "姓不能为空"
			            });
			            return false;
					}else{
						if(firstnameArr[i]['languageVal'] == 'English'){
							if(!firstnameArr[i]['firstnameVla'].match(/[a-zA-Z]+/)){
								layer.open({
					                title: false,
					                type: 0,
					                content: "只能输入英文！"
					            });
								return false;
							}
						}else if(firstnameArr[i]['languageVal']){
							if(!firstnameArr[i]['firstnameVla'].match(/[\u4e00-\u9fa5]+/)){
								layer.open({
					                title: false,
					                type: 0,
					                content: "只能输入中文！"
					            });
								return false;
							}
						}
					};
				};
				var secondnameArr = [];
				$('input[data-name="secondname"]').each(function(i){
					secondnameArr.push({'secondnameVla':$(this).val(),'languageVal':$(this).attr('language')});
				})
				for(var i =0; i<secondnameArr.length;i++){
					if(secondnameArr[i]['secondnameVla'] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "名不能为空"
			            });
			            return false;
					}else{
						if(secondnameArr[i]['languageVal'] == 'English'){
							if(!secondnameArr[i]['secondnameVla'].match(/[a-zA-Z]+/)){
								layer.open({
					                title: false,
					                type: 0,
					                content: "只能输入英文！"
					            });
								return false;
							}
						}else if(secondnameArr[i]['languageVal']){
							if(!secondnameArr[i]['secondnameVla'].match(/[\u4e00-\u9fa5]+/)){
								layer.open({
					                title: false,
					                type: 0,
					                content: "只能输入中文！"
					            });
								return false;
							}
						}
					};
				};
				
				
					birth_placeVal = $('input[data-name="birth_place"]').val(),
					need_birthdayVal = $('input[data-name="need_birthday"]').val(),
					phoneVal = $('input[data-name="phone"]').val();

				var identitynumArr = [];
				$('input[data-name="identitynum"]').each(function(i){
					identitynumArr.push($(this).val());
				});
				for(var i =0; i<identitynumArr.length;i++){
					if(identitynumArr[i] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "证件编号不能为空！"
			            });
						return false;
					};
				};
				var identity_start_dateArr = [];
				$('input[data-name="identity_start_date"]').each(function(i){
					identity_start_dateArr.push($(this).val());
				});
				for(var i =0; i<identity_start_dateArr.length;i++){
					if(identity_start_dateArr[i] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "证件生效日期不能为空！"
			            });
						return false;
					};
				};

				var identity_expire_dateArr = [];
				$('input[data-name="identity_expire_date"]').each(function(i){
					identity_start_dateArr.push($(this).val());
				});
				for(var i =0; i<identity_expire_dateArr.length;i++){
					if(identity_start_dateArr[i] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "证件失效日期不能为空！"
			            });
						return false;
					};
				};
				var nationalityArr = [];
				$('input[data-name="nationality"]').each(function(i){
					nationalityArr.push($(this).val());
				});
				for(var i =0; i<nationalityArr.length;i++){
					if(nationalityArr[i] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "国籍不能为空！"
			            });
						return false;
					};
				};
				var birth_placeArr = [];
				$('input[data-name="birth_place"]').each(function(i){
					birth_placeArr.push($(this).val());
				});
				for(var i =0; i<birth_placeArr.length;i++){
					if(birth_placeArr[i] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "出生地不能为空！"
			            });
						return false;
					};
				};
				var need_birthdayArr = [];
				$('input[data-name="birthday"]').each(function(i){
					need_birthdayArr.push($(this).val());
				});
				for(var i =0; i<need_birthdayArr.length;i++){
					if(need_birthdayArr[i] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "出生日期不能为空！"
			            });
						return false;
					};
				};
				var phoneArr = [];
				$('input[data-name="phone"]').each(function(i){
					phoneArr.push($(this).val());
				});
				for(var i =0; i<phoneArr.length;i++){
					if(phoneArr[i] == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "联系电话不能为空！"
			            });
						return false;
					};
				};
				var pickupplace_iVal = $('input[data-name="pickupplace_i"]').val(),
					emailVal = $('input[data-name="email"]').val(),
					remarkVal = $('input[data-name="remark"]').val();
				if(emailVal == ''){
					layer.open({
		                title: false,
		                type: 0,
		                content: "邮箱不能为空！"
		            });
					return false;
				}else{
					if(!emailVal.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
						layer.open({
			                title: false,
			                type: 0,
			                content: "邮箱格式有误，请重新输入！"
			            });
						return false;
					}
				};

				var needinvoiceVal = $('input[name=needinvoice]:checked').val(),
					invoicetitleVal = $('input[data-name="invoicetitle"]').val(),
					express_receiverVal = $('input[data-name="express_receiver"]').val(),
					express_phoneVal = $('input[data-name="express_phone"]').val(),
					express_addressVal = $('input[data-name="express_address"]').val(),
					express_codeVal = $('input[data-name="express_code"]').val();
					console.log(needinvoiceVal,invoicetitleVal);
				if(needinvoiceVal == 1 || needinvoiceVal == "1"){
					if(invoicetitleVal == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "抬头不能为空！"
			            });
						return false;
					};
					if(express_receiverVal == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "收件人不能为空！"
			            });
						return false;
					};
					if(express_phoneVal == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "电话不能为空！"
			            });
						return false;
					};
					if(express_addressVal == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "地址不能为空！"
			            });
						return false;
					};
					if(express_codeVal == ''){
						layer.open({
			                title: false,
			                type: 0,
			                content: "邮编不能为空！"
			            });
						return false;
					};
				};

				dataObj['questionlist']=[];
				for(var i = 0;i<$('[question-id]').length;i++){
					var qObj = $('[question-id]').eq(i),
						qObjKey = qObj.attr('question-id');
					dataObj['questionlist'].push({'id':qObjKey,'answer':qObj.val()});
				};
				//规格数据
				if($('#specs').val()){
					dataObj['speclist']=[];
					var specArrAll = $('#specs').val().split(';');
					for(var i = 0 ;i < specArrAll.length;i++){
						var specidObj = {};
						specidObj['specid'] = specArrAll[i].split('$')[0];
						specidObj['num'] = specArrAll[i].split('$')[2];
						dataObj['speclist'].push(specidObj);
					};
				}
				// 选项数据
				if($('#options').val()){
					dataObj['optionlist']=[];
					var optionArrAll = $('#options').val().split(';');
					for(var i = 0 ;i < optionArrAll.length;i++){
						var optionObj = {};
						optionObj['optionid'] = optionArrAll[i].split('$')[0];
						optionObj['num'] = optionArrAll[i].split('$')[2];
						dataObj['optionlist'].push(optionObj);
					};
				};
				// 选项数据
				dataObj['travelerlist']=[];
				for(var i = 0; i<$('.lkxx-modle').length;i++){
					var travelObj = {},
						$this = $('.lkxx-modle').eq(i),
						$tItems = $this.find('[data-name]');
					for(var k = 0 ;k<$tItems.length;k++){
						var tKey = $tItems.eq(k).attr('data-name'),
							tVal = $tItems.eq(k).val();
						travelObj[tKey] = tVal;
					}
					dataObj['travelerlist'].push(travelObj);
				}
			    //订单数据
				dataObj['order'] = {
				    "pId": $('#pid').val(),
				    "skuid": $('#skuid').val(),
				    "traveldate": $('#startdate').val(),
				    "express_receiver": $('#express_receiver').val(),
				    "express_phone": $('#express_phone').val(),
				    "express_address": $('#express_address').val(),
				    "express_postcode": $('#express_postcode').val(),
				    "pickup_place": $('#pickup_place').val(),
				    "pickup_address": $('#pickup_address').val(),
				    "pickupcode": $('#pickupcode').val(),
				    "dropoff_place": $('#dropoff_place').val(),
				    "dropoff_address": $('#dropoff_address').val(),
				    "dropoffcode": $('#dropoffcode').val(),
				    "email": $('#confirmemail').val(),
				    "remark": $('#sremark').val(),
				    "couponcode": $('#couponcode').val(),
				    "needinvoice": $('input:radio[name=needinvoice]:checked').val(),
				    "invoicetitle": $('#invoicetitle').val()
				};
				console.log(dataObj);
			    $.ajax({
			        type: 'POST',
			        url: comHost + '/Play/Order',
			        contentType: "application/json; charset=utf-8",
			        data: JSON.stringify(dataObj),
			        dataType: "jsonp",
			        jsonp: 'jsonpCallback',
			        beforeSend: function () {
			            $('.loding').show();
			        },
			        success: function (data) {
			            $('.loding').hide();
			            if (data.result != "ok") {
			                layer.open({
			                    title: false,
			                    type: 0,
			                    content: data.msg
			                });
			            } else {

			                window.location.href = comHost + '/Pay/OrderPay?id=' + data.orderid;

			            }
			        }
			    });
			});
		}
	}
}
//支付页面
expelocal.orderPay = function(){
	return {
		init:function(){
			var _this = this;
			_this.payWayFun();
		},
		//支付方式
		payWayFun:function(){
			$('.pay-tab-tit').on('click','a',function(){
				var _index = $(this).index(),
					$this = $(this);
				$this.addClass('cur').siblings('a').removeClass('cur');
				$('.pay-tab-main').hide().eq(_index).show();
				$('.pay-tab-main').eq(_index).show();
			});
		}
	}
}

//Cookies{{{
window.Cookies = {
    set: function (name, value) {
        var argv = arguments;
        var argc = arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : '/';
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
    },
    get: function (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        var j = 0;
        while (i < clen) {
            j = i + alen;
            if (document.cookie.substring(i, j) == arg)
                return Cookies.getCookieVal(j);
            i = document.cookie.indexOf(" ", i) + 1;
            if (i == 0)
                break;
        }
        return null;
    },
    clear: function (name) {
        if (Cookies.get(name)) {
            var expdate = new Date();
            expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
            Cookies.set(name, "", expdate);
        }
    },
    getCookieVal: function (offset) {
        var endstr = document.cookie.indexOf(";", offset);
        if (endstr == -1) {
            endstr = document.cookie.length;
        }
        return unescape(document.cookie.substring(offset, endstr));
    }

};